import { getParkingTypeRequest } from "@/apis/parkingType"
import { makeAutoObservable, runInAction } from "mobx"
import { makePersistable } from "mobx-persist-store"

export interface parkingLotTypeInter {
	hourNum: number,
	startNum: number,
	monthNum: number,
	dayNum: number,
	notes: string,
	id: number
}

export class parkingLotTypeStore {
	parkingLotType: parkingLotTypeInter[] = []
	constructor() {
		makeAutoObservable(this)
		makePersistable(this, {
			name: 'parkingLotTypeStore',
			properties: ['parkingLotType'],
			storage: window.localStorage,
		})
	}
	setParkingLotType(parkingLotType: parkingLotTypeInter[]) {
		this.parkingLotType = parkingLotType
	}

	//向后端请求
	getParkingLotTypeRequest() {
		getParkingTypeRequest().then((res: any) => {
			runInAction(() => {
				this.parkingLotType = res.result
			})
		})
	}
}
